Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   




pop( ) FUNCTION


The 'pop( )' Function can be used to remove an item from the Dictionary.


Let us say, we want to remove the entry where the 'Key' is '5' and 'Value' is 'Is a Number'.


5, Is a Number

Example :


x = {
    5 : "Is a Number", 
    "John": "Is a Name", 
    "Python": "Is a Language"
}
x.pop(5)
print(x)


Output :



  {'John': 'Is a Name', 'Python': 'Is a Language'}

So, in the above code we have created a 'Dictionary' using braces '{ }' and 'Key' and 'Value' pairs.


x = {
    5 : "Is a Number", 
    "John": "Is a Name", 
    "Python": "Is a Language"
}

And initialised to the variable 'x'.


java_Collections

Now, we are supposed to delete the value of the 'Key', '5'.


So, we have used the below way to update it.


x.pop(5)

And the entry for the 'Key' '5' is deleted for the 'Dictionary'.


java_Collections

And we get the below output,


Output :



  {'John': 'Is a Name', 'Python': 'Is a Language'}